#import<DouyinOpenSDK/DouyinOpenSDKApplicationDelegate.h>
#import "AppDelegate.h"
#import "GeneratedPluginRegistrant.h"
#import "FlutterDouyinPlugin.h"


@interface AppDelegate () <DouyinOpenSDKLogDelegate>

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    NSLog(@"抖音组件初始化");
    
    [[DouyinOpenSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
    [DouyinOpenSDKApplicationDelegate sharedInstance].logDelegate = self;
    [GeneratedPluginRegistrant registerWithRegistry:self];
//     [FlutterDouyinPlugin registerWithRegistrar: [self registrarForPlugin:@"FlutterDouyinPlugin"]];
    // Override point for customization after application launch.
    return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
- (BOOL)application:(UIApplication *)application openURL:(nonnull NSURL *)url options:(nonnull NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
    
    if ([[DouyinOpenSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey] annotation:options[UIApplicationOpenURLOptionsAnnotationKey]]
        ) {
        return YES;
    }
    
    return NO;
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    
    if ([[DouyinOpenSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation]) {
        return YES;
    }
    
    return NO;
}

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    if ([[DouyinOpenSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:nil annotation:nil]) {
        return YES;
    }
    return NO;
}
#pragma mark
- (void)registerLogDelegate
{
    [DouyinOpenSDKApplicationDelegate sharedInstance].logDelegate = self;
}


- (void)onLog:(NSString *) logInfo
{
    NSLog(@"抖音平台:%@", logInfo);
}
@end
